const mongoose = require('mongoose')
const user = 'jackMg'
const password = 'KKmg8848!!'
const mongoDBUrl = `mongodb+srv://${user}:${password}@cluster0.pdhpx.mongodb.net/test?retryWrites=true&w=majority`
// 连接 MongoDB 数据库
mongoose.connect(
  mongoDBUrl,
  {
    useNewUrlParser: true,
    useUnifiedTopology: true,
  },
  () => {
    console.log('连接MongoDB成功')
  }
)
const mongoDB = mongoose.connection
mongoDB.on('error', console.error)
module.exports = mongoose
